<template>
  <el-container>
    <el-header>喵喵网管理后台，欢迎：<span style="color: yellow">{{$store.state.user.username}}</span></el-header>
    <el-container>
      <el-aside width="200px">
        <el-menu default-active="1">
        <el-menu-item index="1">
          <i class="el-icon-menu"></i>
          <router-link tag="span" to="/admin/users" slot="title">用户管理</router-link>
        </el-menu-item>
        <el-menu-item index="2">
          <i class="el-icon-setting"></i>
          <router-link tag="span" to="/admin/movie" slot="title">电影管理</router-link>
        </el-menu-item>
        <el-menu-item index="3">
          <i class="el-icon-setting"></i>
          <router-link tag="span" to="/admin/cinema" slot="title">影院管理</router-link>
        </el-menu-item>
      </el-menu>
      </el-aside>
      <el-main>
        <keep-alive>
          <router-view></router-view>
        </keep-alive>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import axios from 'axios'
export default {
  async beforeRouteEnter(to, from, next) {
    let res = await axios.get('/api2/admin')
    if(res.data.status === 0) {
      next()
    }else {
      next('/mine/login')
    }
  }
}
</script>

<style scoped>
.el-header, .el-footer {
  background-color: #B3C0D1;
  color: #333;
  text-indent: 2rem;
  line-height: 60px;
}

.el-aside {
  background-color: #D3DCE6;
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #E9EEF3;
  color: #333;
  text-align: center;
}
</style>
